/**
 */
package org.mro.grib.model.files.secondEdition.dataRepresentations.impl;

import java.nio.ByteBuffer;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.mro.grib.model.files.secondEdition.dataRepresentations.DataRepresentationTemplate5200;
import org.mro.grib.model.files.secondEdition.dataRepresentations.DataRepresentationsPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Data Representation Template5200</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate5200Impl#getNumberOfBitsUsedForEachPackedValue <em>Number Of Bits Used For Each Packed Value</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate5200Impl#getMv <em>Mv</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate5200Impl#getMvl <em>Mvl</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate5200Impl#getDecimalScaleFactor <em>Decimal Scale Factor</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate5200Impl#getMvlListOffset <em>Mvl List Offset</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DataRepresentationTemplate5200Impl extends EObjectImpl implements DataRepresentationTemplate5200 {
	/**
	 * The default value of the '{@link #getNumberOfBitsUsedForEachPackedValue() <em>Number Of Bits Used For Each Packed Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfBitsUsedForEachPackedValue()
	 * @generated
	 * @ordered
	 */
	protected static final byte NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getNumberOfBitsUsedForEachPackedValue() <em>Number Of Bits Used For Each Packed Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfBitsUsedForEachPackedValue()
	 * @generated
	 * @ordered
	 */
	protected byte numberOfBitsUsedForEachPackedValue = NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE_EDEFAULT;

	/**
	 * The default value of the '{@link #getMv() <em>Mv</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMv()
	 * @generated
	 * @ordered
	 */
	protected static final short MV_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getMv() <em>Mv</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMv()
	 * @generated
	 * @ordered
	 */
	protected short mv = MV_EDEFAULT;

	/**
	 * The default value of the '{@link #getMvl() <em>Mvl</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMvl()
	 * @generated
	 * @ordered
	 */
	protected static final short MVL_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getMvl() <em>Mvl</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMvl()
	 * @generated
	 * @ordered
	 */
	protected short mvl = MVL_EDEFAULT;

	/**
	 * The default value of the '{@link #getDecimalScaleFactor() <em>Decimal Scale Factor</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDecimalScaleFactor()
	 * @generated
	 * @ordered
	 */
	protected static final byte DECIMAL_SCALE_FACTOR_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getDecimalScaleFactor() <em>Decimal Scale Factor</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDecimalScaleFactor()
	 * @generated
	 * @ordered
	 */
	protected byte decimalScaleFactor = DECIMAL_SCALE_FACTOR_EDEFAULT;

	/**
	 * The default value of the '{@link #getMvlListOffset() <em>Mvl List Offset</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMvlListOffset()
	 * @generated
	 * @ordered
	 */
	protected static final long MVL_LIST_OFFSET_EDEFAULT = 0L;

	/**
	 * The cached value of the '{@link #getMvlListOffset() <em>Mvl List Offset</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMvlListOffset()
	 * @generated
	 * @ordered
	 */
	protected long mvlListOffset = MVL_LIST_OFFSET_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DataRepresentationTemplate5200Impl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DataRepresentationsPackage.Literals.DATA_REPRESENTATION_TEMPLATE5200;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getNumberOfBitsUsedForEachPackedValue() {
		return numberOfBitsUsedForEachPackedValue;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNumberOfBitsUsedForEachPackedValue(byte newNumberOfBitsUsedForEachPackedValue) {
		byte oldNumberOfBitsUsedForEachPackedValue = numberOfBitsUsedForEachPackedValue;
		numberOfBitsUsedForEachPackedValue = newNumberOfBitsUsedForEachPackedValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE, oldNumberOfBitsUsedForEachPackedValue, numberOfBitsUsedForEachPackedValue));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public short getMv() {
		return mv;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMv(short newMv) {
		short oldMv = mv;
		mv = newMv;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MV, oldMv, mv));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public short getMvl() {
		return mvl;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMvl(short newMvl) {
		short oldMvl = mvl;
		mvl = newMvl;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MVL, oldMvl, mvl));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getDecimalScaleFactor() {
		return decimalScaleFactor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDecimalScaleFactor(byte newDecimalScaleFactor) {
		byte oldDecimalScaleFactor = decimalScaleFactor;
		decimalScaleFactor = newDecimalScaleFactor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__DECIMAL_SCALE_FACTOR, oldDecimalScaleFactor, decimalScaleFactor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public long getMvlListOffset() {
		return mvlListOffset;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMvlListOffset(long newMvlListOffset) {
		long oldMvlListOffset = mvlListOffset;
		mvlListOffset = newMvlListOffset;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MVL_LIST_OFFSET, oldMvlListOffset, mvlListOffset));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE:
				return getNumberOfBitsUsedForEachPackedValue();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MV:
				return getMv();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MVL:
				return getMvl();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__DECIMAL_SCALE_FACTOR:
				return getDecimalScaleFactor();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MVL_LIST_OFFSET:
				return getMvlListOffset();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE:
				setNumberOfBitsUsedForEachPackedValue((Byte)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MV:
				setMv((Short)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MVL:
				setMvl((Short)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__DECIMAL_SCALE_FACTOR:
				setDecimalScaleFactor((Byte)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MVL_LIST_OFFSET:
				setMvlListOffset((Long)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE:
				setNumberOfBitsUsedForEachPackedValue(NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MV:
				setMv(MV_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MVL:
				setMvl(MVL_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__DECIMAL_SCALE_FACTOR:
				setDecimalScaleFactor(DECIMAL_SCALE_FACTOR_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MVL_LIST_OFFSET:
				setMvlListOffset(MVL_LIST_OFFSET_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE:
				return numberOfBitsUsedForEachPackedValue != NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MV:
				return mv != MV_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MVL:
				return mvl != MVL_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__DECIMAL_SCALE_FACTOR:
				return decimalScaleFactor != DECIMAL_SCALE_FACTOR_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE5200__MVL_LIST_OFFSET:
				return mvlListOffset != MVL_LIST_OFFSET_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (numberOfBitsUsedForEachPackedValue: "); //$NON-NLS-1$
		result.append(numberOfBitsUsedForEachPackedValue);
		result.append(", mv: "); //$NON-NLS-1$
		result.append(mv);
		result.append(", mvl: "); //$NON-NLS-1$
		result.append(mvl);
		result.append(", decimalScaleFactor: "); //$NON-NLS-1$
		result.append(decimalScaleFactor);
		result.append(", mvlListOffset: "); //$NON-NLS-1$
		result.append(mvlListOffset);
		result.append(')');
		return result.toString();
	}

	/* (non-Javadoc)
	 * @see org.mro.grib.model.files.secondEdition.dataRepresentations.IDataRepresentation#initialise(java.nio.ByteBuffer)
	 */
	@Override
	public void initialise(ByteBuffer buffer) {
		numberOfBitsUsedForEachPackedValue = buffer.get();
		mv = buffer.getShort();
		mvl = buffer.getShort();
		decimalScaleFactor = buffer.get();
		mvlListOffset = buffer.position();
	}
	
} //DataRepresentationTemplate5200Impl
